/**
	 * 根据名称，返回如1,2,3类似的值，中间以逗号分隔 
	 */
	function getValuesByCheckTagEx(){
		var val = document.getElementsByTagName("input");
		var str ='';
		
		if(val){	
			for(var i=0,len = val.length;i<len;i++){
				if (val[i].type == 'checkbox'){
					if(val[i].checked){
						str += val[i].value+',';
					}
				}
			}
			return str.substring(0,str.length-1);
		}
		return str;
	}
	
	
	function getValuesByunCheckTag(){
		var val = document.getElementsByTagName("input");
		var str ='';
		
		if(val){	
			for(var i=0,len = val.length;i<len;i++){
				if (val[i].type == 'checkbox'){
					if(val[i].checked==false){
						str += val[i].value+',';
					}
				}
			}
			return str.substring(0,str.length-1);
		}
		return str;
	}
	
	///查看没有选中的。
	function existsStrings(strings,value){
		if (strings == null || strings == ""){
			return false;
		}
		var strs = strings.split(",");
		for (var index = 0 ; index < strs.length ; index++){
			if (strs[index] == value){
				return true;
			}
		}
		return false;
	}
	
	function setCheckedTag(strings){
		if (strings == null || strings==""){
			return;
		}
		var val = document.getElementsByTagName("input");
		
		if(val){	
			for(var i=0,len = val.length;i<len;i++){
				if (val[i].type == 'checkbox'){
					val[i].checked = existsStrings(strings,val[i].value);
				}
			}
		}
	}

function gotoPage(event, gotoPage, totalPage, form, currentPage){
	
	 
  if(!/^\d*$/.test($F(gotoPage))){
    alert("您输入的页码有误，请重新输入");
    Event.stop(event);
    return false;
  }

  if(parseFloat($F(gotoPage)) > parseFloat(totalPage)){
    alert("您输入的页码太大，请重新输入");
    gotoPage.value = totalPage;
    	Event.stop(event);
    return false;
  }else if($F(gotoPage) < 1){
    gotoPage.value = 1;
  }
  
  document.getElementById("pageCheckIds").value= repeatCheckBoxAndIsNumber(getAllCheckBox());
  currentPage.value =$F(gotoPage);
  form.submit();
}

function repeatCheckBoxAndIsNumber(strings){
	if (strings != null &&  strings != ""){
		var stringArray = strings.split(",");
		var result = "";
		for (var index = 0 ; index < stringArray.length ; index++){
			if (!isNaN(stringArray[index]) && !existsStrings(result,stringArray[index])){
				result += stringArray[index]+',';
			}
		}
		return   result.substring(0,result.length-1);
	}
	//isNaN(
	return "";
}

function getAllCheckBox(){
	
	var unIds = getValuesByunCheckTag();
	  var ids = "";
	  ids = getValuesByCheckTagEx();
	  
	  
	  
	  var pageCheckIds = document.getElementById("pageCheckIds").value;
	  if (ids.length > 0){
		  if (pageCheckIds.length > 0){
			  pageCheckIds = pageCheckIds + "," + ids;
		  } else {
			  pageCheckIds = ids;
		  }
	  }
	  //existsStrings
	  if (pageCheckIds != null || pageCheckIds != ""){
		  var strings = pageCheckIds.split(",");
		  var str = "";
		  for (var index = 0 ; index < strings.length ; index++){
			  if (!existsStrings(unIds,strings[index])){
				  str += strings[index]+',';
			  }
		  }
		  pageCheckIds = str.substring(0,str.length-1);
	  }
	  return pageCheckIds;
}


